<?php
/**
 * Description of MediaService
 *
 * @author Magno
 */
class MediaService {

    private $mediaDAO;
    public function __construct() {
        $this->mediaDAO = new MediaDAO();
    }

    public function salvar($media) {
        try {
            return $this->mediaDAO->salvar($media);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function excluir($mediaID) {

        try {
            if(!isset ($mediaID) || $mediaID <= 0)
                throw new Exception("Codigo do Media Nao Econtrado!!!");

            $this->mediaDAO->excluir($mediaID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function listar($pagina = 0,$caminho = "") {
        try {
            return $this->mediaDAO->listar($pagina, $caminho);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function buscarPorID($mediaID) {
        try {
            if(!isset ($mediaID) || $mediaID <= 0)
                throw new Exception("Codigo do Media Nao Econtrado!!!");
            $this->mediaDAO->buscarPorID($mediaID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function total($caminho = "") {
        try {
            return $this->mediaDAO->total($caminho);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }
}
?>
